const express = require('express')

const app = express()

app.listen(80, () => {
    console.log('express server running: http://127.0.0.1')
})


// 处理get请求
app.get('/user', function (req, resp) {
    resp.send({ mane: 'zs', age: 20, gender: '男' })
})

// post
app.post('/user', function (req, resp) {
    resp.send('请求成功')
})


// 获取get查询参数
app.get('/', function (req, resp) {

    console.log(req.query)
    resp.send(req.query)
})

// 获取restful参数
app.get('/user/:id/:name', function (req, resp) {

    console.log(req.params)
    resp.send(req.params)
})


// 对外提供静态资源
app.use('/public', express.static('./clock'))
// app.use(express.static('./clock'))

// 托管多个静态资源目录，则多调用几次express.static